import { defineNuxtPlugin } from '#app'
import { gsap } from 'gsap'
import { ScrollTrigger } from 'gsap/ScrollTrigger'
import { ScrollToPlugin } from 'gsap/ScrollToPlugin'
import { DrawSVGPlugin } from 'gsap/DrawSVGPlugin'
import { Observer } from 'gsap/Observer' // 专门导入Observer插件
import { MorphSVGPlugin } from 'gsap/MorphSVGPlugin'
import { CustomEase } from 'gsap/CustomEase'
import { CustomWiggle } from 'gsap/CustomWiggle'
import { Physics2DPlugin } from 'gsap/Physics2DPlugin'



export default defineNuxtPlugin((nuxtApp) => {
  // 注册 ScrollTrigger 和 ScrollToPlugin 插件
  gsap.registerPlugin(ScrollTrigger, ScrollToPlugin, Observer, MorphSVGPlugin, CustomWiggle, CustomEase, Physics2DPlugin)

  // 将 GSAP 提供给所有 Vue 组件
  // 提供全局访问
  nuxtApp.provide('CustomEase', CustomEase)
  nuxtApp.provide('CustomWiggle', CustomWiggle)
  nuxtApp.provide('Observer', Observer)
  nuxtApp.provide('gsap', gsap)
  nuxtApp.provide('ScrollTrigger', ScrollTrigger)
  nuxtApp.provide('DrawSVGPlugin', DrawSVGPlugin)
})